using System;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.System;

namespace Ascended.SPOT.Sensors.Distance
{
    public interface UltrasonicSensor : IDisposable
    {
        float GetDistance();
        float GetDistanceinCm();
    }

    public class MB1200 : UltrasonicSensor
    {
        protected AnalogIn sensor;

        public MB1200(Cpu.Pin pin)
        {
            sensor = new AnalogIn((AnalogIn.Pin)pin);
            sensor.SetLinearScale(0, 1024);
        }

        public float GetDistance()
        {

            return sensor.Read();
        }

        public float GetDistanceinCm()
        {
            return 0f;
            //return GetTemperatureInC() * 9 / 5 + 32;
        }
        
        public void Dispose()
        {
            sensor.Dispose();
            sensor = null;
        }
    }
}